package cn.edu.ctbu.finaltest.service.AdministratorSelectCourseService.impl;

import cn.edu.ctbu.finaltest.exception.REnum;
import cn.edu.ctbu.finaltest.service.AdministratorSelectCourseService.AdministratorSelectCourseService;
import cn.edu.ctbu.finaltest.vo.AdministratorSelectCourse;
import cn.edu.ctbu.finaltest.vo.R;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class AdministratorSelectCourseImplService implements AdministratorSelectCourseService {
//    private String sno;
//    private String sname;
//    private String sex;
//    private String dept;
//    private String cno;
//    private String cname;
//    private String tname;

    public R<List<AdministratorSelectCourse>> findByRCno(String cno, List<AdministratorSelectCourse> ASCList){
        List<AdministratorSelectCourse> administratorSelectCourses = new ArrayList<>();
        for (int i = 0;i < ASCList.size();i++){
            if (cno.equals(ASCList.get(i).getCno())){
                administratorSelectCourses.add(ASCList.get(i));
            }
        }
        R<List<AdministratorSelectCourse>> RAll = new R<>();
        RAll.setData(administratorSelectCourses);
        RAll.setMsg(REnum.SUCCESS.getMsg());
        RAll.setCode(REnum.SUCCESS.getCode());
        return RAll;
    }

    public R<List<AdministratorSelectCourse>> findByRSex(String sex,List<AdministratorSelectCourse> ASCList){
        List<AdministratorSelectCourse> administratorSelectCourses = new ArrayList<>();
        for (int i = 0;i < ASCList.size();i++){
            if (sex.equals(ASCList.get(i).getSex())){
                administratorSelectCourses.add(ASCList.get(i));
            }
        }
        R<List<AdministratorSelectCourse>> RAll = new R<>();
        RAll.setData(administratorSelectCourses);
        RAll.setMsg(REnum.SUCCESS.getMsg());
        RAll.setCode(REnum.SUCCESS.getCode());
        return RAll;
    }


}
